#include "Prog04q2.h"

int main()
{
   List L1, L2;
   Stack S1, S2;
   Position current1, current2;
   FILE *fpr, *fpi;
   Position current;
   int isPalindrome;

   L1 = CreateEmptyList();
   fpr = fopen("linkedlist1.dat", "r");
   if(fpr == NULL)
   {
      printf("\nFailed to open file!\n");
   }
   CreateList(fpr, L1);

   L2 = CreateEmptyList();
   fpi = fopen("linkedlist2.dat", "r");
   if(fpi == NULL)
   {
      printf("\nFailed to open file!\n");
      exit(0);
   }
   CreateList(fpi, L2);

   PrintList(L1);
   PrintList(L2);

   S1 = CreateEmptyStack();
   S1 = CreateStackFromList(L1, S1);

   S2 = CreateEmptyStack();
   S2 = CreateStackFromList(L2, S2);
   
   PrintStack(S1);
   PrintStack(S2);

   isPalindrome = CheckIsPalindrome(L1, S1);
   if(isPalindrome == 0)
   {
      printf("\nThat list is a Palindrome!\n");
   }
   else
   {
      printf("\nThat list is not a Palindrome!\n");
   }

   isPalindrome = CheckIsPalindrome(L2, S2);
   if(isPalindrome == 0)
   {
      printf("\nThat list is a Palindrome!\n");
   }
   else
   {
      printf("\nThat list is not a Palindrome!\n");
   }

   return 0;
}
